package com.brilliance.project.service.impl;

import java.util.List;

import org.apache.commons.logging.Log;

import com.brilliance.project.common.exception.BrillianceException;
import com.brilliance.project.service.IBaseService;
import com.brilliance.project.webapp.form.BaseForm;

public class BaseService implements IBaseService {
	@Override
	public List<BaseForm> query(BaseForm baseForm, Log log) {
		List<BaseForm> list = null;
		try {
			list = queryImpl(baseForm, log);
		} catch (BrillianceException e) {
			log.error(e.getExMessage());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

	public List<BaseForm> queryImpl(BaseForm baseForm, Log log)
			throws Exception {
		throw new Exception("没有实现queryImpl具体方法！");
	}

	@Override
	public List<BaseForm> queryByPg(BaseForm baseForm, Log log) {
		List<BaseForm> list = null;
		try {
			list = queryByPgImpl(baseForm, log);
		} catch (BrillianceException e) {
			log.error(e.getExMessage());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

	public List<BaseForm> queryByPgImpl(BaseForm baseForm, Log log)
			throws Exception {
		throw new Exception("没有实现queryByPgImpl具体方法！");
	}

	@Override
	public boolean insert(BaseForm baseForm, Log log) {
		try {
			return insertImpl(baseForm, log);
		} catch (BrillianceException e) {
			log.error(e.getExMessage());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	public boolean insertImpl(BaseForm baseForm, Log log) throws Exception {
		throw new Exception("没有实现insertImpl具体方法！");
	}

	@Override
	public boolean delete(BaseForm baseForm, Log log) throws Exception {
		try {
			return deleteImpl(baseForm, log);
		} catch (BrillianceException e) {
			log.error(e.getExMessage());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	public boolean deleteImpl(BaseForm baseForm, Log log) throws Exception {
		throw new Exception("没有实现deleteImpl具体方法！");
	}

	@Override
	public boolean update(BaseForm baseForm, Log log) {
		try {
			return updateImpl(baseForm, log);
		} catch (BrillianceException e) {
			log.error(e.getExMessage());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	public boolean updateImpl(BaseForm baseForm, Log log) throws Exception {
		try {
			return updateImpl(baseForm, log);
		} catch (BrillianceException e) {
			log.error(e.getExMessage());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}

	@Override
	public Object doAnything(Object obj, Log log) {
		try {
			return doAnythingImpl(obj, log);
		} catch (BrillianceException e) {
			log.error(e.getExMessage());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public Object doAnythingImpl(Object obj, Log log) throws Exception {
		throw new Exception("没有实现doAnythingImpl具体方法！");
	}

}
